package com.jxdinfo.hussar.cloud.module.example.tjjc.towertimecount.controller;

import com.jxdinfo.hussar.cloud.module.example.tjjc.towertimecount.model.TowerTimeCount;
import com.jxdinfo.hussar.cloud.module.example.tjjc.towertimecount.service.TowerTimeCountService;
import com.jxdinfo.hussar.cloud.module.example.tjjc.towertimecount.vo.TowerTimeCountChartVO;
import com.jxdinfo.hussar.cloud.module.example.tjjc.towertimecount.vo.TowerTimeCountSearchVO;
import com.jxdinfo.hussar.cloud.module.example.tjjc.towertimecount.vo.TowerTimeCountVO;
import com.jxdinfo.hussar.platform.core.base.apiresult.ApiResponse;
import com.jxdinfo.hussar.support.audit.core.annotations.AuditLog;
import com.jxdinfo.hussar.support.audit.core.enums.AuditEventGrade;
import com.jxdinfo.hussar.support.audit.core.enums.AuditEventType;
import com.jxdinfo.hussar.support.mp.base.controller.HussarBaseController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 塔机工时统计控制器
 */
@RestController(value = "tjjc.towertimecount.TowerTimeCountController")
@AuditLog(moduleName = "塔机工时统计")
@RequestMapping(value = "/tjjc/towerTimeCount")
public class TowerTimeCountController extends HussarBaseController<TowerTimeCount, TowerTimeCountService> {

    private static final Logger logger = LoggerFactory.getLogger(TowerTimeCountController.class);

    @Autowired
    private TowerTimeCountService towerTimeCountService;

    /**
     * 塔机工时分析图表
     * @param towerTimeCountSearchVO 入参
     * @return 查询结果
     */
    @AuditLog(moduleName = "塔机工时统计", eventDesc = "塔机工时分析图表", eventGrade = AuditEventGrade.SERVICE_LOG_TYPE, evnetType = AuditEventType.QUERY)
    @PostMapping(path = "findByChart")
    public ApiResponse<List<TowerTimeCountChartVO>> findByChart(@RequestBody TowerTimeCountSearchVO towerTimeCountSearchVO){
        if (towerTimeCountSearchVO == null){
            return null;
        }

        //todo 没有获取项目编号工具类

        return towerTimeCountService.findByChart(towerTimeCountSearchVO);
    }

    /**
     * 获取工时列表信息
     * @param towerTimeCountSearchVO 入参
     * @return 查询结果
     */
    @AuditLog(moduleName = "塔机工时统计", eventDesc = "塔机工时分析图表", eventGrade = AuditEventGrade.SERVICE_LOG_TYPE, evnetType = AuditEventType.QUERY)
    @PostMapping(path = "findByList")
    public ApiResponse<List<TowerTimeCountVO>> findByList(@RequestBody TowerTimeCountSearchVO towerTimeCountSearchVO){
        //todo 没有获取项目编号工具类

        return towerTimeCountService.findByList(towerTimeCountSearchVO);
    }
}
